/*
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores
 * CA 94065 USA or visit www.oracle.com if you need additional information or
 * have any questions.
 */
package com.sun.lwuit;

import java.io.IOException;

/**
 * Allows embedding a video into a LWUIT component, video creation/management is
 * very platform specific and this component tries to abstract that logic as much
 * as possible while maintaining portability.
 * <p>Notice that unlike the previous implementation these implementations completely
 * hide the underlying MMAPI (or other) interface. To access it directly you can extract
 * the Player/VideoControl instance (if applicable in this implementation) by invoking
 * getClientProperty("Player")/getClientProperty("VideoController"). This behavior is
 * implementation specific and we encorage implementations to expose such features via
 * the client property facility.
 *
 * @author Shai Almog
 */
public abstract class VideoComponent extends PeerComponent {
    /**
     * This constructor is used internally by the LWUIT implementation class
     * 
     * @param nativePeer the native peer
     */
    protected VideoComponent(Object nativePeer) {
        super(nativePeer);
        setFocusable(false);
    }

    /**
     * Some devices might not allow extracting the native peer before the first initialization
     * 
     * @param nativePeer the native peer
     */
    protected void setNativePeer(Object nativePeer) {
        super.setNativePeer(nativePeer);
    }

    /**
     * Creates a new instance of the video component
     *
     * @param videoInfo a platform specific video source identifier, a string with a video URL
     * is most common although some platforms might support an input stream or some other information
     * @param type the video type if required by the native platform
     * @return a LWUIT Video component that can be manipulated just like any other
     * LWUIT component but would internally encapsulate the given video
     */
    public static VideoComponent create(Object videoInfo, String type) throws IOException {
        return Display.getInstance().getImplementation().createVideoPeer(videoInfo, type);
    }


    /**
     * Start media playback implicitly setting the component to visible
     */
    public abstract void start();

    /**
     * Stope media playback
     */
    public abstract void stop();

    /**
     * Set the number of times the media should loop
     *
     * @param count the number of times the media should loop
     */
    public abstract void setLoopCount(int count);

    /**
     * Return the duration of the media
     *
     * @return the duration of the media
     */
    public abstract int getMediaTimeSeconds();

    /**
     * "Jump" to a point in time within the media
     *
     * @param now the point in time to "Jump" to
     * @return the media time in microseconds
     */
    public abstract int setMediaTimeSeconds(int now);

    /**
     * Toggles the fullscreen mode
     *
     * @param fullscreen true for fullscreen mode
     */
    public abstract void setFullScreen(boolean fullscreen);

    /**
     * Indicates the fullscreen mode
     *
     * @return true for fullscreen mode
     */
    public abstract boolean isFullScreen();
}
